{{- if .IsHome -}}
    {{- $posts := .Site.Params.home.posts -}}
    {{- if ne $posts.enable false | and .Site.RegularPages -}}
        {{- $pages := where .Site.RegularPages "Type" "in" site.Params.mainSections -}}
        {{- if .Site.Params.page.hiddenFromHomePage -}}
            {{- $pages = where $pages "Params.hiddenfromhomepage" false -}}
        {{- else -}}
            {{- $pages = where $pages "Params.hiddenfromhomepage" "!=" true -}}
        {{- end -}}
        {{- with $posts.paginate | default .Site.Params.paginate -}}
            {{- $pages = $.Paginate $pages . -}}
        {{- else -}}
            {{- $pages = .Paginate $pages -}}
        {{- end -}}
        {{- .Scratch.Set "paginatorPager" $pages -}}
    {{- end -}}

{{- else if and .IsSection .Pages -}}
    {{- $pages := .Pages.GroupByDate "2006" -}}
    {{- with .Site.Params.section.paginate | default .Site.Params.paginate -}}
        {{- $pages = $.Paginate $pages . -}}
    {{- else -}}
        {{- $pages = .Paginate $pages -}}
    {{- end -}}
    {{- .Scratch.Set "paginatorPager" $pages -}}
{{- else if and (eq .Kind "term") .Pages -}}
    {{- $taxonomy := .Data.Singular -}}
    {{-  $pages := .Pages.ByParam "series_weight" -}}
    {{- if eq $taxonomy "series" -}}
        {{- $pages = .Pages.ByParam "series_weight" -}}
        {{- with .Site.Params.list.paginate | default .Site.Params.paginate -}}
            {{- $pages = $.Paginate $pages . -}}
        {{- else -}}
            {{- $pages = .Paginate $pages -}}
        {{- end -}}
    {{- else -}}
        {{- $pages = .Pages.GroupByDate "2006" -}}
        {{- with .Site.Params.list.paginate | default .Site.Params.paginate -}}
            {{- $pages = $.Paginate $pages . -}}
        {{- else -}}
            {{- $pages = .Paginate $pages -}}
        {{- end -}}
    {{- end -}}
    {{- .Scratch.Set "paginatorPager" $pages -}}
{{- end -}}
